package cn.vconinfo.app.response;


import cn.vconinfo.app.enums.ServiceReturnCode;

import java.io.Serializable;

/**
 * @author vconinfo
 * @createdOn 2019/07/22
 * @description: 服务通用返回参数
 */
public class ServiceReturn<T> implements Serializable {
    private static final long serialVersionUID = 650319527278832852L;
    T data;
    ServiceReturnCode returnCode;
    String message;

    public ServiceReturn(T data) {
        this.generate(data, ServiceReturnCode.SUCCESS, "");
    }
    public ServiceReturn(T data, ServiceReturnCode returnCode) {
        this.generate(data, returnCode, "");
    }
    public ServiceReturn(T data, ServiceReturnCode returnCode, String message) {
        this.generate(data, returnCode, message);
    }
    public ServiceReturn(ServiceReturnCode returnCode, String message) {
        this.generate(null, returnCode, message);
    }
    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public ServiceReturnCode getReturnCode() {
        return returnCode;
    }

    public void setReturnCode(ServiceReturnCode returnCode) {
        this.returnCode = returnCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void generate(T data, ServiceReturnCode code, String message){
        this.setData(data);
        this.setReturnCode(code);
        this.setMessage(message);

    }
}
